package com.chushouya.manager.constants;

import lombok.Getter;

import java.util.Objects;

/**
 * 短信模板配置
 */
@Getter
public enum SmsTemplateEnum {
    DYNAMIC_TEMPLATE("DYNAMIC_TEMPLATE", "通知类模板", "通知类模板"),
    APP_LOGIN_CODE("SMS_290957152", "登录验证码", "您的验证码为：${code}，该验证码5分钟内有效，请勿泄露于他人！"),

    ;

    SmsTemplateEnum(String code, String name, String content) {
        this.code = code;
        this.name = name;
        this.content = content;
    }

    private String code;

    private final String name;

    private final String content;

    public void setCode(String code) {
        this.code = code;
    }

    public static SmsTemplateEnum getByTemplateKey(String code) {
        for (SmsTemplateEnum thisEnum : SmsTemplateEnum.values()) {
            if (Objects.equals(thisEnum.code, code)) {
                return thisEnum;
            }
        }
        return null;
    }

    public static SmsTemplateEnum dynamicTemplate(String code) {
        final SmsTemplateEnum dynamicTemplate = SmsTemplateEnum.DYNAMIC_TEMPLATE;
        dynamicTemplate.setCode(code);
        return dynamicTemplate;
    }

}
